﻿@model XPressify.Models.MessageCreateModel


@if(Model.IsAjaxRequest)
{
    ViewBag.Title = Model.ThreadSubject;
}
else
{
    ViewBag.Title = Model.ThreadSubject;
    Layout = "~/Views/Shared/_Layout.cshtml";
}



@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset>
         
        <legend style="font-size:x-large;color:#222">@Model.ThreadSubject</legend>
        <p align="right" style="margin:0px">
            @Html.ActionLink("Mark as unread", "MakeAsUnread", "Thread", new { id = Model.ThreadId }, new { @class = "abtn" }) &nbsp; &nbsp; 
            <input type="button" value="Back" class="abtn" onclick="history.go(-1);" /> 
        </p>    

        <table>
            <tr>
                <th  style="width:50px">User</th>
                <th width="250px"></th>
                <th>Message</th>
            </tr>
            @{  var index = 0;
                foreach (var message in Model.PreviousMessages)
                {
                    <tr>
                        <td>
                            <a href='@Url.Action("ProfileView", "Profile", new { id = message.BaseSubject.Id })' class="nobtn">
                                        <img src= "@Model.CreatorProfilePicturePath[index]" alt="Profile picture" title="Profile picture" style="width: 50px;height: 50px;" />
                            </a>
                        </td>
                        <td>
                            @Html.ActionLink(message.BaseSubject.FullName, "ProfileView", "Profile", new { id = message.BaseSubject.Id }, new {@class = "nobtn" })
                            <br />
                            @message.Created.ToString("dd MMMM, yyyy a't' HH:mm")
                        </td>
                        <td style="color:#222">@message.Body</td>
                    </tr>
                    <tr>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                       index++;
                } 
              }   
                <tr>
                    <td style="vertical-align:top">
                        <a href='@Url.Action("ProfileView", "Profile", new { id = Model.CurrentUser.Id })' class="nobtn">
                                <img src= "@Model.CurrentUserProfilePicturePath" alt="Profile picture" title="Profile picture" style="width: 50px;height: 50px;" />
                        </a>
                    </td>
                    <td style="vertical-align:top">
                        <a href='@Url.Action("ProfileView", "Profile", new { id = Model.CurrentUser.Id })' class="nobtn">
                                @Model.CurrentUserName
                        </a>
                        
                    </td>
                    <td>
                        @Html.TextAreaFor(model => model.Message, 12, 81, new { style = "resize: none;" })
                    </td>
                </tr>
            </table>
            <p>
                <input type="submit" value="Send"/>
            </p>
            @Html.HiddenFor(model => model.ThreadId)
            
    </fieldset>
            
}
